<template>
  <div class="consultation-approval">
    <el-card shadow="never">
      <template #header>
        <h2>会诊审批</h2>
      </template>
      
      <el-table :data="approvalData" stripe>
        <el-table-column prop="patientName" label="患者姓名" />
        <el-table-column prop="disease" label="疾病" />
        <el-table-column prop="applicant" label="申请人" />
        <el-table-column prop="urgency" label="紧急程度">
          <template #default="{ row }">
            <el-tag :type="getUrgencyColor(row.urgency)">{{ row.urgency }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态">
          <template #default="{ row }">
            <el-tag :type="getStatusColor(row.status)">{{ row.status }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="{ row }">
            <el-button type="success" size="small" @click="handleApprove(row)">通过</el-button>
            <el-button type="danger" size="small" @click="handleReject(row)">拒绝</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'

const approvalData = ref([
  {
    patientName: '张三',
    disease: '肺癌',
    applicant: '李医生',
    urgency: '紧急',
    status: '待审批'
  }
])

const getUrgencyColor = (urgency: string) => {
  const map: Record<string, string> = {
    '普通': 'info',
    '紧急': 'warning',
    '特急': 'danger'
  }
  return map[urgency] || 'info'
}

const getStatusColor = (status: string) => {
  const map: Record<string, string> = {
    '待审批': 'warning',
    '已通过': 'success',
    '已拒绝': 'danger'
  }
  return map[status] || 'info'
}

const handleApprove = (row: any) => {
  ElMessage.success(`审批通过: ${row.patientName}`)
}

const handleReject = (row: any) => {
  ElMessage.error(`审批拒绝: ${row.patientName}`)
}
</script>

<style lang="scss" scoped>
.consultation-approval {
  h2 {
    margin: 0;
    color: #303133;
  }
}
</style>